import request from '@/utils/request'

// 登录接口
export const adminLoginService = (loginForm: Object) => {
  return request.post(`/teacher/login`, loginForm)
}

// 获取公告接口
export const adminGetNotificationService = (searchForm: Object) => {
  return request.post(`/teacher/notification`, searchForm)
}

// 获取话题列表接口
export const adminGetTopicListService = (type: Number) => {
  return request.get(`/teacher/topic/${type}`)
}

// 获取话题详细接口
export const adminGetTopicDetailService = (id: any) => {
  return request.get(`/teacher/topic`, {
    params: {
      id: id
    }
  })
}

// 获取评论接口，一次5条
export const adminGetCommentListService = (currentPage: Number, topicId: any) => {
  return request.get(`/teacher/topic/comment`, {
    params: {
      currentPage,
      topicId
    }
  })
}

// 发表评论接口
export const adminAddCommentService = (content: String, topicId: any) => {
  console.log(content, topicId)
  return request.put(`/teacher/topic`, {
    content: content,
    topicId: topicId
  })
}

// 暂存话题草稿接口
export const adminSaveTopicDraftService = (topicForm: Object) => {
  return request.post('/teacher/topic/draft', topicForm)
}

// 获取草稿
export const adminGetTopicDraftService = () => {
  return request.get(`/teacher/topic/draft`)
}

// 发布话题
export const adminPublishTopicService = (topicForm: Object) => {
  return request.post(`/teacher/topic`, topicForm)
}

// 保存公告草稿
export const adminSaveNotificationDraftService = (form: Object) => {
  return request.post(`/teacher/notification/draft`, form)
}

// 获取公告草稿
export const adminGetNotificationDraftService = () => {
  return request.get(`/teacher/notification/draft`)
}

// 发布公告
export const adminPublishNotificationDraftService = (form: Object) => {
  return request.post(`/teacher/notification/publish`, form)
}

// 删除公告
export const adminDeleteNotificationService = (id: any) => {
  return request.delete(`/teacher/notification`, {
    params: {
      id: id
    }
  })
}

// 删除话题
export const adminDeleteTopicService = (id: any) => {
  return request.delete(`/teacher/topic`, {
    params: {
      id
    }
  })
}

// 上传视频
export const adminUploadVideoService = (form: Object) => {
  return request.post(`/teacher/video/add`, form)
}

// 获取视频列表
export const adminGetVideoList = (form: Object) => {
  return request.post(`/teacher/video`, form)
}

// 获取具体的视频播放
export const adminGetVideoDetailService = (id: any) => {
  console.log(id)
  return request.get(`/teacher/video/${id}`)
}

// 删除视频资源
export const adminDeleteVideoService = (id: any) => {
  return request.delete(`/teacher/video/${id}`)
}

// 上传文档
export const adminUploadDocumentService = (form: Object) => {
  return request.post(`/teacher/document/add`, form)
}

// 获取文档列表
export const adminGetDocumentList = (form: Object) => {
  return request.post(`/teacher/document`, form)
}

// 获取具体的文档预览
export const adminGetDocumentDetailService = (id: any) => {
  console.log(id)
  return request.get(`/teacher/document/${id}`)
}

// 删除文档资源
export const adminDeleteDocumentService = (id: any) => {
  return request.delete(`/teacher/document/${id}`)
}

// 上传课件
export const adminUploadCoursewareService = (form: Object) => {
  return request.post(`/teacher/courseware/add`, form)
}

// 获取课件列表
export const adminGetCoursewareList = (form: Object) => {
  return request.post(`/teacher/courseware`, form)
}

// 获取具体的课件预览
export const adminGetCoursewareDetailService = (id: any) => {
  console.log(id)
  return request.get(`/teacher/courseware/${id}`)
}

// 删除课件资源
export const adminDeleteCoursewareService = (id: any) => {
  return request.delete(`/teacher/courseware/${id}`)
}

// 保存试卷
export const adminSaveTestPaperService = (form: Object) => {
  return request.post(`/teacher/test/paper/save`, form)
}

// 试卷主页
export const adminGetPaperListService = (form: Object) => {
  return request.post(`/teacher/test/paper`, form)
}

// 保存试卷的题目和选项，正确答案
export const adminSaveTestQuestionsService = (form: Object, id: any) => {
  return request.post(`/teacher/test/question/save`, form, {
    params: {
      id
    }
  })
}

// 获取试卷的题目和选项，正确答案
export const adminGetQuestionsService = (id: any) => {
  return request.get(`/teacher/test/question/${id}`)
}

// 根据id获取试卷的题目和选项，正确答案
export const adminGetPaperByIdService = (id: any) => {
  return request.get(`/teacher/test/paper/${id}`)
}

// 根据id删除试卷
export const adminDeletePaperService = (id: any) => {
  return request.delete(`/teacher/test/paper/${id}`)
}

// 根据id发布试卷
export const adminPublishPaperService = (id: any) => {
  return request.put(`/teacher/test/paper/${id}`)
}

// 根据paperId获取
export const adminGetScoreListService = (id: any) => {
  return request.get(`/teacher/statistics/${id}`)
}

// 获取各个分数段的人数
export const adminGetScoreDistributionService = (id: any) => {
  return request.get(`/teacher/statistics/distribution/${id}`)
}

// 获取用户的基本信息
export const adminGetUserInfoService = () => {
  return request.get('/teacher/user')
}

// 修改用户信息
export const adminUpdateUserInfoService = (form: Object) => {
  return request.post(`/teacher/user`, form)
}

// 删除评论
export const adminDeleteCommentService = (id: any) => {
  return request.delete(`/teacher/topic/comment/${id}`)
}

// 导出学生成绩
export const adminExportScoreService = (id: any) => {
  return request.get(`/teacher/statistics/export/${id}`, {
    responseType: 'blob'
  })
}

// 获取所有学生信息
export const adminGetManagementListService = (pageForm: Object) => {
  return request.post(`/teacher/management/list`, pageForm)
}

// 更改学生账号状态
export const adminUpdateStatusService = (id: any, status: any) => {
  return request.put(`/teacher/management/status`, {
    id,
    status
  })
}

// 设置学生的默认密码
export const adminUpdateDefaultPasswordService = (id: any) => {
  return request.put(`/teacher/management/password/${id}`)
}

// 修改密码
export const adminEditPasswordService = (passwordForm: Object) => {
  return request.post(`/teacher/user/password`, passwordForm)
}

// 统计每个模块的内容数量
export const adminGetContentCountService = () => {
  return request.get(`/teacher/statistics/count`)
}

// 给出删除话题的理由
export const adminAskReasonTopicService = (reason: Object) => {
  return request.post(`/teacher/topic/delete`, reason)
}

// 给出删除评论的理由
export const adminAskReasonCommentService = (reason : Object)=>{
  return request.post(`/teacher/topic/comment/delete`, reason)
}

export const adminRegisterService = (form: Object) => {
  return request.post(`/teacher/register`, form)
}
